
var form = layui.form;
var $ = layui.jquery;
var layer = layui.layer;
var element = layui.element;
var laypage = layui.laypage;
var laytpl = layui.laytpl;
var laydate = layui.laydate;
var upload = layui.upload;

function formSubmit(url,submit,dataType,func){
	form.on(submit,function(data){
		ajax(url,data.field,dataType,func);
	});
}
function ajax(url,field,dataType,func){
	$.ajax({
		url:base.app+url,
		data:field,
		dataType:dataType,
		type:"post",
		success:func
	});
}
function toJsp(url){
	location.href = base.app + url;
}
function goJspRegister(){
	toJsp("/web/register.jsp")
}
function goJspLogin(){
	toJsp("/web/login.jsp")
}
function getlaytpl(sel,data){
	return laytpl($(sel).html()).render(data);
}
function openLayer(url,end){
	layer.open({
		type:2,
		area:['800px','500px'],
		fixed:false,//不固定
		maxmin:true,//可最大化最小化
		end:end,//可关闭
		content:base.app +url
	});
}
function closeThis(){
	var index = parent.layer.getFrameIndex(window.name);
	parent.layer.close(index);
}
function openConfirm(func,title){
	layer.confirm(title?title:"是否进行该操作？",{
		icon:3,
		title:'提示'
	},func);
}
function setPageInfo(elem,count,curr,limit,jump){
	laypage.render({
	        	elem:elem,
	        	count:count,
	        	curr:curr,
	        	limit:limit,
	        	limits:[ 10,20,30,40,50 ],
	        	layout:[ 'count','prev','page','next','limit','skip'],
	        	jump:jump
	        });
}
function renderUpload(id,url,data,done){
	 var uploadInst = upload.render({
		 elem : '#' +id,
		 url : base.app+url,
		 data :data,
		 done :done
	 });
}